import java.util.Arrays;
import java.util.Scanner;

public class test_4_16 {
    public static void main(String[] args) {
        int[] arr = new int[100];
        Scanner in = new Scanner(System.in);
        System.out.print("您想输入多少个数：");
        int n = in.nextInt();
        System.out.print("请输入数据：");
        for (int i = 0; i < n; i++){
            arr[i] = in.nextInt();
        }
        for (int i = 0; i < n- 1; i++){
            for (int j = 0; j < n - 1 - i; j++){
                if (arr[j] > arr[j + 1]){
                    int b = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = b;
                }
            }
        }
        System.out.print("排序后的数据：");
        for (int i = 0; i < n; i++){
            System.out.print(arr[i] + " ");
        }
        System.out.print("\n您想查找哪个数字：");
        int l = in.nextInt();
        int right = n - 1;
        int left = 0;
        int mid = 0;
        int a = 0;
        while (right >= left){
            mid = (left + right) / 2;
            if (arr[mid] == l){
                System.out.print(l + "在排序后第" + (mid + 1) + "位。");
                a = 1;
                break;
            }else if (arr[mid] > l) {
                right = mid  - 1;
            }else{
                left = mid + 1;
            }
        }
        if (a == 0){
            System.out.print("没有找到您想要的数。");
        }
    }
}
